package com.estate.business.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.estate.business.TenderSuccService;
import com.estate.dao.TenderSuccDao;
import com.estate.utils.DeleProjectUtil;
import com.estate.vo.Vo;
import com.estate.vo.impl.DeleProjectVo;
import com.estate.vo.impl.TenderSuccVo;
import com.estate.vo.impl.TenderVo;
import com.estate.vo.impl.UserInfoVo;

public class TenderSuccServiceImpl implements TenderSuccService {

	private TenderSuccDao tenderSuccDao;

	public TenderSuccDao getTenderSuccDao() {
		return tenderSuccDao;
	}

	public void setTenderSuccDao(TenderSuccDao tenderSuccDao) {
		this.tenderSuccDao = tenderSuccDao;
	}
	
	public boolean addTenderSucc(TenderSuccVo tenderSucc){
		boolean result =false; 
		result = this.getTenderSuccDao().addVo(tenderSucc);
		return result;
	}

	public List<Vo> getList(){
		List<Vo> allList = this.getTenderSuccDao().findAll();
		return allList;
	}

	public TenderSuccVo getTenderSucc(int id){
		TenderSuccVo project = (TenderSuccVo) this.getTenderSuccDao().findByPK(id);
		return project;
	}

	public boolean updateTenderSucc(TenderSuccVo tenderSucc){
		boolean result =false;
		TenderSuccVo old = this.getTenderSucc(tenderSucc.getId());
		tenderSucc.setPostDate(old.getPostDate());
		tenderSucc.setPostUser(old.getPostUser());
		tenderSucc.setTender(old.getTender());
		result = this.getTenderSuccDao().updateVo(tenderSucc);
		return true;
	}
	
	public boolean deleteMultiTenderSucc(String delStr){
		if(delStr!= null && !"".equals(delStr) && !",".equals(delStr)){
			String[] delArray = delStr.split(",");
			TenderSuccVo tenderSucc = null;
			for(int i = 0;i<delArray.length;i++){
				tenderSucc = new TenderSuccVo();
				tenderSucc.setId(Integer.parseInt(delArray[i]));
				this.deleteTenderSucc(tenderSucc);
			}
		}
		return true;
	}
	
	public boolean deleteTenderSucc(TenderSuccVo tenderSucc){
		boolean result = false;
		result = this.getTenderSuccDao().deleteVo(tenderSucc);
		return result;
	}
}
